package com.example.xxljobdemo.job;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class SimpleXxlJob {
    @XxlJob("demoJobHandler")
    public void demoJobHandler() {
        int index=XxlJobHelper.getShardIndex();
        int total=XxlJobHelper.getShardTotal();
        System.out.println("执行定时任务,执行时间:"+new Date());
        System.out.println("index: "+index +  ", total: "+ total);
    }

}
